package org.kineticsproject.devices.parsers;

public class UnitConverter {
	
	public static double lowpassfilter (double gain, double alpha, double beta)
	{
	return(alpha + (gain*(beta-alpha)));
	}

	public static long lowpassfilter (double gain, long alpha, long beta)
	{
	return(alpha + (long)(gain*(double)(beta-alpha)));
	}
	
/*	public static double lowpassfilter (double gain, double alpha, double beta)
	{
	return(alpha + (long)(gain*(beta-alpha)));
	}
	*/
	public static double MilestoKilometers(double miles)
	{		
		return(miles * 1.609344);
	}
	
	public static double KilometerstoMiles(double km)
	{
		return(km / 1.609344);
	}
	
	public static double CentimeterstoMiles(long centimeters)
	{
		return(KilometerstoMiles(centimeters/100.0/1000.0));
	}
	
	public static double CentimeterstoInches(double centimeters)
	{
		return(centimeters*0.393700787);
	}
	
	public static double CentimeterstoFeet(double centimeters)
	{
		return(centimeters*0.393700787/12.0);
	}
	
	public static double CentimeterstoMeters(double centimeters)
	{
		return(centimeters/100.0);
	}
	
	public static double MeterstoCentimeters(double meters)
	{
		return(meters*100.0);
	}
	

	public static double KilometerstoMeters(double kilometers)
	{
		return(kilometers/1000.0);
	}
	
	public static double FeettoMeters(double feet)
	{
		return(feet * 0.3048);
	}
	
	public static double FeettoCentimeters(double feet)
	{
		return(feet * 30.48);
	}
	
	public static double FeettoMiles(double feet)
	{
		return(feet / 5280);
	}
	
	public static double MetersperSecondtoKilometersperHour(long mps)
	{
		double kph = (((double)mps)/1000)/3600;
		return kph;
	}
	
	public static double MetersperSecondtoMilesperHour(long mps)
	{
		double mph = ((((double)mps)/1000)/3600)*1.609344;
		return(mph);
	}
	
	public static double MilesperHourtoMetersperSecond(double mph)
	{
		double mps;
		double kilometers = MilestoKilometers(mph);
	
		// kilometers/hour * 1000 meters / kilometer 60 minutes / hour * 60 seconds / minute = meters/second
		mps = ((long)(kilometers/1000))/3600; 
		return(mps);
	}

}
